#include <iostream>
#include <queue>
using namespace std;

struct Node {
    int data;
    Node* left;
    Node* right;
    Node(int d, Node* l, Node* r) {
        data = d;
        left = l;
        right = r;
    }
};

void level_order(Node* root) {
    queue<Node*> q;
    q.push(root);

    while (!q.empty()) {
        Node* cur = q.front();
        q.pop();

        cout << cur->data << " ";
        Node* lNode = cur->left;
        Node* rNode = cur->right;

        if (lNode) {
            q.push(lNode);
        }
        if (rNode) {
            q.push(rNode);
        }
    }
}

int main() {
    Node* a = new Node(1, nullptr, nullptr);
    Node* b = new Node(2, a, nullptr);
    Node* e = new Node(5, nullptr, nullptr);
    Node* f = new Node(6, nullptr, nullptr);
    Node* d = new Node(4, e, f);
    Node* c = new Node(3, b, d);
    level_order(c);
    return 0;
}